package com.ellricky.baselib.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.ellricky.baselib.ui.ImageFragment;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class ImageAdapter extends FragmentPagerAdapter {
    private List<String> urls;
    private boolean canZoom;

    public ImageAdapter(FragmentManager fm, List<String> urls,boolean canZoom) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.urls = urls;
        this.canZoom = canZoom;
    }

    @NotNull
    @Override
    public Fragment getItem(int position) {
        return ImageFragment.getInstance(urls.get(position),canZoom);
    }

    @Override
    public int getCount() {
        return urls == null ? 0 : urls.size();
    }
}